Update ty results for v0.0.65 - #2325
Merged
JelleZijlstra merged 1 commit intoJul 31, 2026
Merged
Conversation
charliermarsh
marked this pull request as ready for review
July 31, 2026 17:36
charliermarsh
added a commit
to astral-sh/ruff
that referenced
this pull request
Jul 31, 2026
## Summary
Reject specialization of a subclass after all generic parameters in its
bases have been specialized, including by defaults.
```python
T = TypeVar("T")
DefaultT = TypeVar("DefaultT", default=str)
class Base(Generic[T, DefaultT]): ...
class Child(Base[int]): ...
Child[bytes] # error: Child is not generic
```
The existing fallback treated any class with `Generic` anywhere in its
MRO as generic. That fallback predates our support for legacy generic
contexts and is now overly broad: `Generic` remains in the runtime MRO
even when the class has no free type variables. Actual generic class
literals are already accepted through their generic context, so we can
remove the MRO fallback and report `not-subscriptable` for other
classes.
This brings ty into conformance with the
`generics_defaults_specialization.py` case from
[python/typing#2325](python/typing#2325) and
adds focused mdtest coverage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates ty's conformance results from v0.0.50 to v0.0.65.